import request from '@/request'


export function getCommentsByArticle(id) {
  return request({
    url: `/comments/article/${id}`,
    method: 'get'
  })
}

export function publishComment(comment,token) {
  return request({
    headers: {'Authorization': token},
    url: '/comments/create/change',
    method: 'post',
    data: comment
  })
}

export function getComments(token, page, formData) {
  return request({
    headers: {'Authorization': token},
    url: `/comments/admin/all`,
    method: 'post',
    data: {
      page: page.pageNumber,
      pageSize: page.pageSize,
      articleId: formData.articleId,
      status: formData.status,
      level: formData.level,
      authorId: formData.authorId,
      toUid: formData.toUid,
      timeStart: formData.timeStart,
      timeEnd: formData.timeEnd

    }
  })
}

export function changeCommentStatus(token, id, newStatus){
  return request({
    headers: {'Authorization': token},
      url: `/comments/admin/${id}/${newStatus}`,
      method: 'post'
  })
}

export function deleteComment(token, id){
  return request({
    headers: {'Authorization': token},
      url: `/comments/admin/delete/${id}`,
      method: 'post'
  })
}
